package com.jianjian.test;

import com.mchange.v2.c3p0.ComboPooledDataSource;
import org.junit.jupiter.api.Test;

import java.beans.PropertyVetoException;
import java.sql.Connection;
import java.sql.SQLException;

/**
 * @author Zsir
 * @create 2021-12-12 13:35
 */
public class testC3P0 {

    @Test
    public void test1() throws PropertyVetoException, SQLException {
        //创建数据源
        ComboPooledDataSource dataSource = new ComboPooledDataSource();
        //设置数据库连接参数
        dataSource.setDriverClass("com.mysql.cj.jdbc.Driver");
        dataSource.setJdbcUrl("jdbc:mysql://localhost:3306/mybatis?useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false");
        dataSource.setUser("root");
        dataSource.setPassword("jian");

        //获取连接
        Connection connection = dataSource.getConnection();
        System.out.println(connection);
    }
}
